<template>
	<view class="content">

		<view class="logo">
			<image src="../../../../static/activity/retirement/logo.png" mode=""></image>
		</view>

		<view class="word">
			<view class="wordK">光阴似箭，岁月如梭。今天迎来了您光荣退休的日子，集团工会谨此之际，向您表示崇高的敬意、亲切的慰问。</view>

			<view class="wordK">
				从朝气蓬勃、干劲冲天的美好年华，到如今两鬓泛白仍宝刀未老，您为柳钢贡献了青春、汗水和智慧。过去的岁日里，您在岗位上，勤勤恳恳，任劳任怨，团结拼搏，用辛勤的劳动，铸就了柳钢的辉煌。
			</view>

			<view class="dianwo">
				<image src="../../../../static/activity/retirement/dianwo.png" mode=""></image>
				<view class="button" v-if="status == 1" @click="button">点击选择</view>
			</view>

			<view class="wordK">“莫道桑榆晚，为霞尚满天”衷心希望您退休后仍有所为，更有所乐；并希望您一如既往地继续关心和支持柳钢的工作和发展。让我们继续荣辱与共，再创辉煌!</view>

			<view class="wordK">柳钢集团工会祝您身体健康，万事如意，阖家幸福!</view>
		</view>

	</view>
</template>
<script>
	export default {
		data() {
			return {
				user: null,
				status: null,
				type: null,
			}
		},
		onLoad(opt) {
			uni.showLoading({
				title: '加载中...'
			});
			if (opt.Bearer) {
				uni.setStorageSync("Bearer", opt.Bearer);
				this.bearer();
			} else if (opt.code) {
				this.loginx(code);
			} else {
				this.user = uni.getStorageSync("member");
				this.audit2024();
				this.audit2025();
			}
		},
		methods: {
			bearer() {
				let self = this
				this.$boya.NGet("/app/auth/user", null, function(res) {
					console.log("bearer: ", res);
					self.user = res.data.member;
					uni.setStorageSync("member", res.data.member);
					uni.showToast({
						title: '登录中...',
						duration: 1000,
						icon: 'loading'
					})
					self.audit2024();
					self.audit2025();
				}, err => {
					console.log('bearerErr: ', err);
					uni.showToast({
						title: '登录失败,请重试',
						duration: 2000,
						icon: 'error'
					});
				}, false, false)
			},
			loginx(code) {
				let self = this
				console.log('code: ', code);
				self.$boya.NPost('/tpi/loginx', {
					code: code
				}, function(res) {
					console.log("loginx", res);
					if (res.code == 200) {
						self.user = res.data.user;
						uni.setStorageSync("member", res.data.user);
						uni.showToast({
							title: '登录中...',
							duration: 1000,
							icon: 'loading'
						})
						self.audit2024();
						self.audit2025();
					} else {
						uni.showToast({
							title: '登录失败,请重试',
							duration: 2000,
							icon: 'error'
						});
					}
				}, false)
			},
			audit2024() {
				let self = this;
				this.$boya.Request({
					url: '/card_availability',
					data: {
						uuid: self.user.uuid,
						card_name: "2024年退休慰问品选择券",
					}
				}, function(res) {
					console.log('auditRes: ', res.data);
					uni.hideLoading();
					if (res.code == 200) {
						if (res.data.status) {
							// res.data.status为1：已审核通过
							// res.data.status为-1：审核不通过通过
							// res.data.status为0：未审核
							// res.data.status为2：已选取
							self.status = res.data.status
							self.type = '2024'
						}
					} else {
						uni.showToast({
							icon: 'error',
							title: res.data
						});
					}
				}, false)
			},
			audit2025() {
				let self = this;
				this.$boya.Request({
					url: '/card_availability',
					data: {
						uuid: self.user.uuid,
						card_name: "2025年退休慰问品选择券",
					}
				}, function(res) {
					console.log('auditRes: ', res.data);
					uni.hideLoading();
					if (res.code == 200 && res.data.status == 1) {
						// res.data.status为1：已审核通过
						// res.data.status为-1：审核不通过通过
						// res.data.status为0：未审核
						// res.data.status为2：已选取
						self.status = res.data.status
						self.type = '2025'
					} else {
						self.$boya.Request({
							url: '/card_availability',
							data: {
								uuid: self.user.uuid,
								card_name: "2025年退休慰问品选择券(新)",
							}
						}, function(res) {
							console.log('auditRes新: ', res.data);
							uni.hideLoading();
							if (res.code == 200 && res.data.status == 1) {
								// res.data.status为1：已审核通过
								// res.data.status为-1：审核不通过通过
								// res.data.status为0：未审核
								// res.data.status为2：已选取
								self.status = res.data.status
								self.type = '2025'
							} else {
								uni.showToast({
									icon: 'error',
									title: res.data
								});
							}
						}, false)
					}
				}, false)
			},
			button() {
				uni.navigateTo({
					url: '/pages/activities/welfare/retire/retire?type=' + this.type
				})
			}
		},
	}
</script>

<style>
	.content {
		width: 100vw;
		min-height: 100vh;
		background-color: #2E4B6C;
		// background: url('../../../../static/activity/retirement/lanjin.png') 100% 100% / 100% 100%;
		/* background: linear-gradient(to top, #57785d, #8d9882, #fff); */
	}

	.logo {
		width: 320rpx;
		height: 60rpx;
		position: absolute;
		bottom: 16rpx;
		right: 20rpx;
	}

	.logo>image {
		width: 100%;
		height: 100%;
	}

	.word {
		color: #EBD6BD;
		margin-top: 25rpx;
		line-height: 60rpx;
		font-size: 35rpx;
	}

	.wordK {
		width: 90%;
		margin: 0 auto;
		text-indent: 2em;
	}

	.dianwo {
		width: 550rpx;
		height: 550rpx;
		margin: 0 auto;
	}

	.dianwo>image {
		width: 100%;
		height: 100%;
	}

	.button {
		color: #D8AF89;
		position: absolute;
		margin-top: -250rpx;
		margin-left: 350rpx;
		font-weight: bold;
	}
</style>